import store from '@/store'

export default {
  // 自定义指令的名字 imgError
  imgError: {
    // 渲染后 inserted(dom,obj,vnode)
    inserted(dom, obj) {
      dom.src = dom.src || obj.value
      dom.onerror = function() {
        dom.src = obj.value
      }
    },
    // 更新后
    componentUpdated(dom, obj) {
      dom.src = dom.src || obj.value
    },
    // 销毁
    unbind(dom) {
      dom.onerror = null
    }
  },
  setButtonPower: {
    inserted(dom, obj) {
      // console.log('setButtonPower', store.state.user.userInfo.roles.points[0])
      // console.log('obj', obj.value)
      if (!store.state.user.userInfo.roles.points.includes(obj.value)) {
        dom.style.display = 'none'
      }
    },
    componentUpdated(dom, obj) {
      if (!store.state.user.userInfo.roles.points.includes(obj.value)) {
        dom.style.display = 'none'
      }
    }
  }
}
